<?php
/**
 * 注：此模板为自动生成模板，需要根据实际情况调整修改
 * 此模板对 无主键/单一主键 表的支持较好，联合主键表在下一版本开发
 */
namespace Data;

use Utils\MyException;

class Statistics_restaurant_day_turnover {

    //数组
    private $array;


    public function __construct ($array){

        $this->array = $array;

        self::setDefault();

    }

    public function getArray() {
        return $this->array;
    }

    public function updateWithArray($array) {
        foreach($array as $key=>$value)
        {
            if(array_key_exists($key,$this->array))
            {
                $this->array = array_merge($this->array,array($key=>$value));
            }
        }
    }



    private function setDefault(){

        if(count($this->array)==0){
            self::setDATE("");
            self::setRESTAURANT_ID("0");
            self::setTURNOVER("0");
            self::setTURNOVER_COMPARE("0");
            self::setTOTAL_FOOD_COUNT("0");
            self::setTOTAL_FOOD_COUNT_COMPARE("0");
            self::setCUSUMOR_COUNT("0");
            self::setCUSUMOR_COUNT_COMPARE("0");
            self::setFOOD_SALED_COUNT("");
            self::setFOOD_SALED_PRICE("");
            self::setCREATED_ON("");
            self::setCREATED_BY("0");
            self::setUPDATED_ON("");
            self::setUPDATED_BY("0");

        }
    }






    public function setDATE($value) {
        $this->array = array_merge ($this->array,array(
            'DATE' => $value));
    }
    public function getDATE(){

        return $this->array ['DATE'];
    }


    public function setRESTAURANT_ID($value) {
        $this->array = array_merge ($this->array,array(
            'RESTAURANT_ID' => $value));
    }
    public function getRESTAURANT_ID(){

        return $this->array ['RESTAURANT_ID'];
    }


    public function setTURNOVER($value) {
        $this->array = array_merge ($this->array,array(
            'TURNOVER' => $value));
    }
    public function getTURNOVER(){

        return $this->array ['TURNOVER'];
    }


    public function setTURNOVER_COMPARE($value) {
        $this->array = array_merge ($this->array,array(
            'TURNOVER_COMPARE' => $value));
    }
    public function getTURNOVER_COMPARE(){

        return $this->array ['TURNOVER_COMPARE'];
    }


    public function setTOTAL_FOOD_COUNT($value) {
        $this->array = array_merge ($this->array,array(
            'TOTAL_FOOD_COUNT' => $value));
    }
    public function getTOTAL_FOOD_COUNT(){

        return $this->array ['TOTAL_FOOD_COUNT'];
    }


    public function setTOTAL_FOOD_COUNT_COMPARE($value) {
        $this->array = array_merge ($this->array,array(
            'TOTAL_FOOD_COUNT_COMPARE' => $value));
    }
    public function getTOTAL_FOOD_COUNT_COMPARE(){

        return $this->array ['TOTAL_FOOD_COUNT_COMPARE'];
    }


    public function setCUSUMOR_COUNT($value) {
        $this->array = array_merge ($this->array,array(
            'CUSUMOR_COUNT' => $value));
    }
    public function getCUSUMOR_COUNT(){

        return $this->array ['CUSUMOR_COUNT'];
    }


    public function setCUSUMOR_COUNT_COMPARE($value) {
        $this->array = array_merge ($this->array,array(
            'CUSUMOR_COUNT_COMPARE' => $value));
    }
    public function getCUSUMOR_COUNT_COMPARE(){

        return $this->array ['CUSUMOR_COUNT_COMPARE'];
    }


    public function setFOOD_SALED_COUNT($value) {
        $this->array = array_merge ($this->array,array(
            'FOOD_SALED_COUNT' => $value));
    }
    public function getFOOD_SALED_COUNT(){

        return $this->array ['FOOD_SALED_COUNT'];
    }


    public function setFOOD_SALED_PRICE($value) {
        $this->array = array_merge ($this->array,array(
            'FOOD_SALED_PRICE' => $value));
    }
    public function getFOOD_SALED_PRICE(){

        return $this->array ['FOOD_SALED_PRICE'];
    }


    public function setCREATED_ON($value) {
        $this->array = array_merge ($this->array,array(
            'CREATED_ON' => $value));
    }
    public function getCREATED_ON(){

        return $this->array ['CREATED_ON'];
    }


    public function setCREATED_BY($value) {
        $this->array = array_merge ($this->array,array(
            'CREATED_BY' => $value));
    }
    public function getCREATED_BY(){

        return $this->array ['CREATED_BY'];
    }


    public function setUPDATED_ON($value) {
        $this->array = array_merge ($this->array,array(
            'UPDATED_ON' => $value));
    }
    public function getUPDATED_ON(){

        return $this->array ['UPDATED_ON'];
    }


    public function setUPDATED_BY($value) {
        $this->array = array_merge ($this->array,array(
            'UPDATED_BY' => $value));
    }
    public function getUPDATED_BY(){

        return $this->array ['UPDATED_BY'];
    }


    public function toInsertCSV() {
        $str="";

        // DATE
        $str .="'". self::getDATE()."',";
        // RESTAURANT_ID
        $str .= "'". self::getRESTAURANT_ID()."',";
        // TURNOVER
        $str .= "'". self::getTURNOVER()."',";
        // TURNOVER_COMPARE
        $str .= "'". self::getTURNOVER_COMPARE()."',";
        // TOTAL_FOOD_COUNT
        $str .= "'". self::getTOTAL_FOOD_COUNT()."',";
        // TOTAL_FOOD_COUNT_COMPARE
        $str .= "'". self::getTOTAL_FOOD_COUNT_COMPARE()."',";
        // CUSUMOR_COUNT
        $str .= "'". self::getCUSUMOR_COUNT()."',";
        // CUSUMOR_COUNT_COMPARE
        $str .= "'". self::getCUSUMOR_COUNT_COMPARE()."',";
        // FOOD_SALED_COUNT
        $str .= "'". self::getFOOD_SALED_COUNT()."',";
        // FOOD_SALED_PRICE
        $str .= "'". self::getFOOD_SALED_PRICE()."',";
        // CREATED_ON
        $str .= "now()" . ",";

        // CREATED_BY
        $str .= "'". self::getCREATED_BY()."',";
        // UPDATED_ON
        $str .= "now()" . ",";

        // UPDATED_BY
        $str .= "'". self::getUPDATED_BY()."'";
        return $str;
    }



    public function toUpdateSet() {
        $str="";

        // RESTAURANT_ID
        $str.= '`RESTAURANT_ID` = "' . self::getRESTAURANT_ID() . '",';

        // TURNOVER
        $str.= '`TURNOVER` = "' . self::getTURNOVER() . '",';

        // TURNOVER_COMPARE
        $str.= '`TURNOVER_COMPARE` = "' . self::getTURNOVER_COMPARE() . '",';

        // TOTAL_FOOD_COUNT
        $str.= '`TOTAL_FOOD_COUNT` = "' . self::getTOTAL_FOOD_COUNT() . '",';

        // TOTAL_FOOD_COUNT_COMPARE
        $str.= '`TOTAL_FOOD_COUNT_COMPARE` = "' . self::getTOTAL_FOOD_COUNT_COMPARE() . '",';

        // CUSUMOR_COUNT
        $str.= '`CUSUMOR_COUNT` = "' . self::getCUSUMOR_COUNT() . '",';

        // CUSUMOR_COUNT_COMPARE
        $str.= '`CUSUMOR_COUNT_COMPARE` = "' . self::getCUSUMOR_COUNT_COMPARE() . '",';

        // FOOD_SALED_COUNT
        $str.= '`FOOD_SALED_COUNT` = "' . self::getFOOD_SALED_COUNT() . '",';

        // FOOD_SALED_PRICE
        $str.= '`FOOD_SALED_PRICE` = "' . self::getFOOD_SALED_PRICE() . '",';

        // CREATED_ON
        $str.= '`CREATED_ON` = "' . self::getCREATED_ON() . '",';

        // CREATED_BY
        $str.= '`CREATED_BY` = "' . self::getCREATED_BY() . '",';

        // UPDATED_ON
        $str .= "UPDATED_ON = now()," ;

        // UPDATED_BY
        $str.= '`UPDATED_BY` = "' . self::getUPDATED_BY(). '"';
        return $str;
    }



    public function toUpdateWhere(){
        $str = "";
        $str .= "`RESTAURANT_ID` = '" . self::getRESTAURANT_ID()."'";
        return $str;
    }

}
